/*********************************************************************
 * PrimeNumberReader.java created on Feb 26, 2010
 *
 * This file is part of Sure Tech Support Portal System. 
 * Copyright @ 2010 Sure Tech (HK) Limited. All rights reserved.
 * Sure Tech PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *********************************************************************/
package demo.concurrent.primefinder;

import java.math.BigInteger;

/**
 * @Author: Mac Wang
 * @Date: Feb 26, 2010 11:49:56 AM 
 * @Email: mac@suretech.com.hk
 */

public class PrimeNumberReader extends Thread {
	private PrimeNumberSource source;
	public PrimeNumberReader(PrimeNumberSource source)
	{
		this.source = source;
	}
	
	@Override
	public void run() 
	{
		BigInteger nextVal=null;
		
		do
		{
			nextVal = source.nextPrime();
			if (nextVal!=null)
				System.out.println(nextVal + ", ");
			else break;
		}while (true);		
	}
}
